1. /* srmststr.cpp by K.Tsuru */
  2. // function ID = 802 BRADIX
  3. /********************************************
  4. SRational class
  5. It sets a value by string in a decimal system.
  6. abcd...xyz/ABCD...XYZ type
  7. It counts first '/' only.
  8. *********************************************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. void SRational::SetString(const char *s){
  13. char* buff = new char[strlen(s)+1];
  14. int slash;
  15. char* pt = buff;
  16. while( (*s != '/') && *s ) *(pt++) = *(s++); //copy the numerator
  17. slash = (*s == '/') ? 1 : 0;
  18. *pt = '\0';
  19. //substitute into SLong objects by string
  20. SLong n, d;
  21. n = buff;
  22. if(slash == 0){ //no '/'
  23. d = 1.0;
  24. } else {
  25. s++; d = s;
  26. }
  27. Set(n, d); // includes radix conversion
  28. delete[] buff;
  29. }

srmststr.cpp : last modifiled at 2015/12/03 21:13:59(747 bytes)
created at 2016/06/26 15:57:35
The creation time of this html file is 2016/09/18 20:28:05 (Sun Sep 18 20:28:05 2016).